import request from '@/request';
import BusinessConstant from '@/constant/BusinessConstant';

const PREFIX = BusinessConstant.ROOT_SERVER + '/collect';

export default class HouseCollectApi {
  /**
   * 更改收藏状态（收藏/取消收藏）
   * @param data
   */
  static changeCollectStatus(data: { houseId: number, tenantId: number, status: number, landlordId: number }) {
    return request({
      method: 'PUT',
      url: `${ PREFIX }`,
      data
    });
  }

  /**
   * 获取收藏状态
   * @param houseId 房屋id
   * @param tenantId 租客id
   */
  static getCollectStatus(houseId: number, tenantId: number) {
    return request({
      method: 'GET',
      url: `${ PREFIX }?houseId=${ houseId }&tenantId=${ tenantId }`,
    });
  }

  /**
   * 获取房屋的收藏数量
   * @param houseIds 房屋id列表
   */
  static getCollectHouseNum(houseIds: string) {
    return request({
      method: 'GET',
      url: `${ PREFIX }/num?houseIdList=${ houseIds }`,
    });
  }

  /**
   * 获取租客的收藏房屋信息
   * @param tenantId
   */
  static getCollectHouseByTenantId(tenantId: number) {
    return request({
      method: 'GET',
      url: `${ PREFIX }/tenant?tenantId=${ tenantId }`
    });
  }
}